//
//  EqpInfo.m
//  Hive
//
//  Created by 惠俊贝 on 15/9/2.
//  Copyright (c) 2015年 ZM. All rights reserved.
//

#import "EqpInfo.h"
#import "GaodeTransform.h"
#import "LonLat.h"

@implementation EqpInfo

+ (EqpInfo *)createEqpInfoWithDic:(NSDictionary *)dic {
    EqpInfo *ei = [[EqpInfo alloc] init];
    ei.Model = [dic objectForKey:@"Model"];                     //1.设备类型
    ei.InternalMun = [dic objectForKey:@"InternalMun"];         //2.内部设备号
    ei.EqpName = [dic objectForKey:@"EqpName"];                 //3.设备名称
    ei.IMEI = [dic objectForKey:@"IMEI"];                       //4.IMEI唯一码
    ei.SimNum = [dic objectForKey:@"SimNum"];                   //5.SIM卡号
    ei.TrdTime = [dic objectForKey:@"TrdTime"];                 //6.销售时间
    ei.ValidFrom = [dic objectForKey:@"ValidFrom"];             //7.设备开通时间
    ei.ValidEnd = [dic objectForKey:@"ValidEnd"];               //8.设备到期时间
    ei.GroupID = [dic objectForKey:@"GroupID"];                 //9.组名ID
    ei.GroupName = [dic objectForKey:@"GroupName"];             //10.组名称
    ei.DeviceID = [dic objectForKey:@"DeviceID"];               //11.设备表
    ei.DeviceOwenerID = [dic objectForKey:@"DeviceOwenerID"];   //12.用户设备表
    ei.Lng = [dic objectForKey:@"Lng"];                         //13经度
    ei.Lat = [dic objectForKey:@"Lat"];                         //14.纬度
    ei.Address = [dic objectForKey:@"Address"];                 //15.地址
    ei.PositionTime = [dic objectForKey:@"PositionTime"];       //16.定位时间
    ei.Type = [dic objectForKey:@"Type"];                       //17.定位类型
    ei.BL = [dic objectForKey:@"BL"];                           //18.电量
    ei.BS = [dic objectForKey:@"BS"];                           //19.设备按压状态
    ei.IsOnline = [dic objectForKey:@"IsOnline"];               //20.在离线
    ei.Status = [dic objectForKey:@"Status"];                   //21.设备状态
    ei.Speed = [dic objectForKey:@"Speed"];                     //22.速度
    
    ei.CarDeviceID = [dic objectForKey:@"CarDeviceID"];      // 车辆设备关系ID
    ei.CarNumber = [dic objectForKey:@"CarNumber"];        // 车牌号
    ei.CarInfoID = [dic objectForKey:@"CarInfoID"];        // 车辆ID
    ei.BLng = [dic objectForKey:@"BLng"];             // 百度地图经度
    ei.BLat = [dic objectForKey:@"BLat"];             // 百度地图纬度
    ei.DeviceMode = [dic objectForKey:@"DeviceMode"];       // 设备模式
    ei.PledgerName = [dic objectForKey:@"PledgerName"];      // 抵押人名字
    ei.PledgementID = [dic objectForKey:@"PledgementID"];     // 抵押人ID
    ei.PledgeCarID = [dic objectForKey:@"PledgeCarID"];      // 抵押人车辆关系
    
    LonLat *aLonlat = [GaodeTransform transform:[ei.Lat doubleValue] :[ei.Lng doubleValue]];
    ei.GDLat = aLonlat.lat;
    ei.GDLng = aLonlat.lon;
    return ei;
}

+ (NSArray *)createEqpInfosWithDicArray:(NSArray *)arr {
    NSMutableArray *rs = [[NSMutableArray alloc] init];
    for ( NSDictionary *dic in arr) {
        [rs addObject:[EqpInfo createEqpInfoWithDic:dic]];
    }
    return rs;
}



@end
